<?php

defined('SYSPATH') or die('Access error!');

class Model_Recommend extends Model
{

    /**
     * 根据产idd获取到推荐的id数组
     * @param type $id
     * @param type $type
     * @return type
     */
    public function get_recommends_id($id, $type)
    {
        $recommend_id = $this->get_col(array('id' => $id, 'type' => $type), 'recommend_id');
        return $recommend_id;
    }

    /**
     * 添加相关内容的推荐位
     * @param type $id
     * @param type $recommend_arr
     */
    public function add_recommend($id, $recommend_arr, $type)
    {
        $this->delete(array('id' => $id));
        if (Arr::validate_arr($recommend_arr))
        {
            foreach ($recommend_arr as $value)
            {
                $this->insert(array('id' => $id, 'recommend_id' => $value, 'type' => $type));
            }
        }
    }

}